<html>
<head><meta charset="utf-8"><title>Optional dependency causing cargo update to fail · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html">Optional dependency causing cargo update to fail</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230576421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kerfuffle <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576421">(Mar 16 2021 at 19:32)</a>:</h4>
<p>I hope this is the correct forum. I have a dependency like this in <code>Cargo.toml</code>:</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="n">blah</span> <span class="o">=</span> <span class="p">{</span> <span class="n">path</span> <span class="o">=</span> <span class="s">"../blah"</span><span class="p">,</span> <span class="n">optional</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
</code></pre></div>
<p>I'm confused because this causes <code>cargo update</code> to fail when the directory doesn't exist, even though it's an optional feature which isn't enabled. Is there a way around this?</p>



<a name="230576583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576583">(Mar 16 2021 at 19:33)</a>:</h4>
<p>Cargo in general requires the whole dependency graph to exist, and captures it in the lockfile.</p>



<a name="230576600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576600">(Mar 16 2021 at 19:33)</a>:</h4>
<p>An optional dependency is still captured in the lockfile.</p>



<a name="230576662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576662">(Mar 16 2021 at 19:34)</a>:</h4>
<p>Your lockfile needs to know what to do if you do enable that feature.</p>



<a name="230576666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576666">(Mar 16 2021 at 19:34)</a>:</h4>
<p>I don't think there's any way to handle a path dependency not existing.</p>



<a name="230576735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Optional%20dependency%20causing%20cargo%20update%20to%20fail/near/230576735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kerfuffle <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Optional.20dependency.20causing.20cargo.20update.20to.20fail.html#230576735">(Mar 16 2021 at 19:34)</a>:</h4>
<p>That's unfortunate but thanks for the response.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>